package com.dong.javalangchain4jai.config;

import com.dong.javalangchain4jai.listener.MyChatModelListener;
import dev.langchain4j.model.chat.ChatLanguageModel;
import dev.langchain4j.model.openai.OpenAiChatModel;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import java.time.Duration;
import java.util.List;

/**
 * 模型配置
 *
 * @author xiedongxiao
 */

@Configuration
public class ChatModelConfig {

    @Primary
    @Bean("qwen-turbo")
    public ChatLanguageModel qwenTurboModel() {
        return OpenAiChatModel.builder()
                .apiKey("sk-62956ab6e0c14e75bc7874d4e7d3305d")
                .modelName("qwen-turbo")
                .baseUrl("https://dashscope.aliyuncs.com/compatible-mode/v1")
                .build();
    }

    @Bean("deepseek-chat")
    public ChatLanguageModel deepseekChatModel() {
        return OpenAiChatModel.builder()
                .apiKey("sk-5761c41f246e4257a0bdec55fa9fde21")
                .modelName("deepseek-chat")
                .baseUrl("https://api.deepseek.com")
                .temperature(0.7)
//                .listeners(List.of(new MyChatModelListener()))
                .maxRetries(3)
                .timeout(Duration.ofSeconds(60))
                .logRequests(true)
                .logResponses(true)
                .build();
    }

}
